package com.yanqu.road.server.manager.activity.jiuzhou.task;

import com.yanqu.road.logic.helper.ActivityHelper;
import com.yanqu.road.server.manager.activity.jiuzhou.CrossJiuZhouMgr;
import com.yanqu.road.server.manager.activity.jiuzhou.activity.CrossJiuZhouActivity;
import com.yanqu.road.utils.executor.GeneralTask;

import java.util.Map;

/**
 * 九州棋局内存释放
 */
public class CrossJiuZhouReleaseMemoryTask extends GeneralTask {

    @Override
    public void doRun() {
        Map<Integer, CrossJiuZhouActivity> activityMap = CrossJiuZhouMgr.getActivityMap();
        if (activityMap == null || activityMap.isEmpty()) {
            return;
        }
        for (CrossJiuZhouActivity activity : activityMap.values()) {
            if (activity.getConfig() != null && !ActivityHelper.activityInShowTime(activity.getConfig().getActivityInfo())) {
                continue;
            }
            try {
                activity.releaseMemoryTask();
            } catch (Exception e) {
                getLOGGER().error("releaseMemoryTask error : ", e);
            }
        }
    }
}
